//
// Created by richa on 2023/9/8.
//
#include "SimModbusTcpPlc.h"

using namespace Sim;

SimModbusTcpPlc::SimModbusTcpPlc(void (*function1)(), int listenPort, void(*init)(unsigned short * D)) {
    this->simPlc = new SimPlc(function1, init);
    std::unique_lock<std::mutex> lock(*this->simPlc->mutex);
    this->simPlc->cv.wait(lock, [this]{ return this->simPlc->initFlag;});
    this->modbusTcp = new ModbusTcp("0.0.0.0", this->simPlc->getMbMapping());
    this->modbusTcp->setListenPort(listenPort);
    this->modbusTcp->startListen();
}
